home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* */
- /* Source - AlternateCDEF.c */
- /* Author - Alexander S. Colwell, Copyright (C) 1988, 1989 */
- /* */
- /* */
- /* Purpose - This is a dual-arrow scroll bar control definition */
- /* procedure. It is similiar to the standard scroll bar */
- /* except this has two arrow indicators on both ends. */
- /* */
- /* Routine - DSControl : Dual scroll bar control definition. */
- /* DSInitControl : Init the control parameters. */
- /* DSCalcThumb : Calculate new thumb position. */
- /* DSDrawThumb : Draw the thumb. */
- /* DSPositionThumb: Re-position the thumb. */
- /* DSSetupThumb : Setup thumb for dragging. */
- /* DSDrawHBtn : Draw high button. */
- /* DSDrawLBtn : Draw low button. */
- /* DSFrameButtons : Draw high and low frames around btns.*/
- /* DSTestControl : Test for part controls. */
- /* DSSetScrollRgn : Set scroll region. */
- /* DSGetBackGround: Get back-ground color. */
- /* DSGetForeGround: Get fore-ground color. */
- /* DSSetBackGround: Set back-ground color. */
- /* DSSetForeGround: Set fore-ground color. */
- /* DSEraseRect : Erase rect area. */
- /* DSFrameRect : Frame rect area. */
- /* DSFillRect : Fill rect area. */
- /* DSErasePoly : Erase poly area. */
- /* DSFramePoly : Frame poly area. */
- /* DSFillPoly : Fill poly area. */
- /* DSDrawObject : Draw object type (ie. rect or poly) */
- /* */
- /* Revisions - 6/27/89 asc : */
- /* * Add fixes to the calculate region relating to 32-bit*/
- /* clean rules in Technical Note # 212. */
- /* * Fix minor bug calculating the "thumb" offset base on*/
- /* the contrlValue's handling negative values. */
- /* 8/17/89 asc : */
- /* * Fix "thumb" calculation bug. Forget to add "break" */
- /* to the next "case" statement. Hence, following thru */
- /* to System 7.0 region calcuation stuff. */
- /* * Fix problem if the control's rect area has been */
- /* scrolled. This is not a problem in the "Alternate */
- /* Demo", but could be in other applications that uses */
- /* "SetOrigin" to offset it's original rect area. Hence*/
- /* the scroll bar would not be properly offseted. */
- /* * Re-work the "up" and "down" arrow buttons to use the*/
- /* "altButton" variable to interface into new THINK C's*/
- /* object library. */
- /* */
- /************************************************************************/
-
- #include <QuickDraw.h> /* QuickDraw defs */
- #include <Color.h> /* Color defs */
- #include <WindowMgr.h> /* Window Manager defs */
- #include <ControlMgr.h> /* Control Manager defs */
- #include <ToolBoxUtil.h> /* Tool Box Utilities defs */
- #include <ColorToolBox.h> /* Color Tool Box defs */
-
- typedef struct { /* Dual Control Data Structure */
- short hasColor; /* Has color monitor flag */
- short altButton; /* Using alternate button */
- Rect thumb; /* Thumb rectangle area */
- Rect cThumb; /* Current thumb rectangle area */
- PolyHandle up; /* Up button handle */
- PolyHandle down; /* Down button handle */
- short bLen; /* Button length */
- short hBLen; /* Half button length */
- short sLen; /* Scroll bar length */
- double tFactor; /* Thumb factor */
- short hFactor; /* Horizontal factor */
- short vFactor; /* Vertical factor */
- ControlHandle cHdl; /* Control handle to reference */
- long blackPat[2]; /* Black pattern */
- long ltGrayPat[2]; /* Light gray pattern */
- } DS;
- typedef DS *DSPTR;
- typedef DSPTR *DSHDL;
-
- typedef struct { /* Thumb Info Data Structure */
- Rect limitRect; /* Limit rect area scrolling */
- Rect slopRect; /* Slop rect area scrolling */
- short axis; /* Drag axis control */
- } THUMB;
- typedef THUMB *THUMBPTR;
- /* Misc definitions */
- #define NIL (0L) /* NIL pointer */
- #define abs(a) (a<0?-a:a) /* Absolute macro function */
- #define min(a,b) (a<b?a:b) /* Minumim macro function */
- #define max(a,b) (a<b?b:a) /* Maximum macro function */
-
- /* Trap definitions */
- #define SysEnvironsTrap 0xa090 /* System Enviorment trap */
- #define UnknownTrap 0xa89f /* Unknown trap instruction */
-
- /* System 7.0 CDEF messages */
- #define calcCntlRgn 10 /* Calculate control's region */
- #define calcThumbRgn 11 /* Calculate "thumb" region */
-
- /* Control's macro procedures */
- #define DSFrameHUpBtn() DSDrawHBtn(dPtr,dPtr->up,FALSE)
- #define DSFrameHDownBtn() DSDrawHBtn(dPtr,dPtr->down,FALSE)
- #define DSFrameLUpBtn() DSDrawLBtn(dPtr,dPtr->up,FALSE)
- #define DSFrameLDownBtn() DSDrawLBtn(dPtr,dPtr->down,FALSE)
- #define DSFillHUpBtn() DSDrawHBtn(dPtr,dPtr->up,TRUE)
- #define DSFillHDownBtn() DSDrawHBtn(dPtr,dPtr->down,TRUE)
- #define DSFillLUpBtn() DSDrawLBtn(dPtr,dPtr->up,TRUE)
- #define DSFillLDownBtn() DSDrawLBtn(dPtr,dPtr->down,TRUE)
-
- #define DSFrameBody(a) DSDrawObject(dPtr->cHdl,DSGetForeGround,DSSetForeGround, \
- DSFrameRect,cFrameColor,a)
- #define DSClearBody(a) DSDrawObject(dPtr->cHdl,DSGetBackGround,DSSetBackGround, \
- DSEraseRect,cBodyColor,a)
- #define DSFillBody(a) DSDrawObject(dPtr->cHdl,DSGetBackGround,DSSetBackGround, \
- DSFillRect,cBodyColor,a,dPtr->ltGrayPat)
- #define DSFrameThumb(a) DSDrawObject(dPtr->cHdl,DSGetForeGround,DSSetForeGround, \
- DSFrameRect,cFrameColor,a)
- #define DSFillThumb(a) DSDrawObject(dPtr->cHdl,DSGetBackGround,DSSetBackGround, \
- DSEraseRect,cThumbColor,a)
- #define DSFrameArrow(a) DSDrawObject(dPtr->cHdl,DSGetForeGround,DSSetForeGround, \
- DSFramePoly,cFrameColor,a)
- #define DSClearArrow(a) DSDrawObject(dPtr->cHdl,DSGetBackGround,DSSetBackGround, \
- DSErasePoly,cBodyColor,a)
- #define DSFillArrow(a) DSDrawObject(dPtr->cHdl,DSGetForeGround,DSSetForeGround, \
- DSFillPoly,cFrameColor,a,dPtr->blackPat)
-
-
- /* Define forward referneces */
- void DSInitControl(),DSDrawThumb(),DSPositionThumb(),DSSetupThumb(),
- DSDrawHBtn(),DSDrawLBtn(),DSGetBackGround(),DSGetForeGround(),
- DSSetBackGround(),DSSetForeGround(),DSFrameButtons(),DSEraseRect(),
- DSFrameRect(),DSFillRect(),DSErasePoly(),DSFramePoly(),DSFillPoly(),
- DSDrawObject();
- long DSTestControl();
-
- pascal long main(varCode,theControl,message,param)
-
- short varCode; /* Variable control code */
- ControlHandle theControl; /* Control handle */
- short message; /* Control message indicator */
- register long param; /* Control parameter value */
-
- {
-
- register ControlPtr cPtr; /* Working control pointer */
- DSHDL dHdl; /* Working dual control handle */
- register DSPTR dPtr = NIL; /* Working dual control pointer */
- Rect wRect; /* Working scroll rect area */
- SysEnvRec sysEnv; /* Working system enviroment */
- long status = 0; /* Working status indicator */
-
- HLock(theControl); /* Lock down the control handle */
-
- cPtr = *theControl; /* Set the control pointer */
-
- if (message != initCntl) { /* Check if already initialized */
-
- if (cPtr->contrlData) { /* Check if valid handle */
-
- HLock(cPtr->contrlData); /* Lock it down for processing */
-
- dPtr = *((DSHDL)cPtr->contrlData);/* Init dual control pointer*/
-
- }
-
- }
-
- switch(message) { /* Process the specified message*/
-
- case drawCntl: /* Draw the control */
-
- if (dPtr) { /* Check if dual pointer valid */
-
- if (cPtr->contrlVis) { /* Check if control is visible */
-
- PenNormal(); /* Setup normal pen characteristics*/
-
- switch(LoWord(param)) {/* Switch on control part */
-
- case 0: /* Re-draw scroll bar */
-
- DSInitControl(dPtr,cPtr);/* Re-init it */
-
- /* Init the scroll bar */
- DSFrameBody(&cPtr->contrlRect);
-
- DSFrameButtons(dPtr);/* Frame the buttons */
- DSFrameHUpBtn();
- DSFrameHDownBtn();
- DSFrameLUpBtn();
- DSFrameLDownBtn();
-
- DSDrawThumb(dPtr,theControl);
-
- break;
-
- case 129: /* Value/Min/Max changed */
-
- DSDrawThumb(dPtr,theControl);
-
- break;
-
- case 0xff: /* Control to be inactive */
-
- DSSetScrollRgn(dPtr,&wRect);/* Set scroll region*/
-
- DSClearBody(&wRect);/* Clear scroll bar */
-
- break;
-
- case inPageUp: /* Hilite scroll bar */
- case inPageDown:
-
- DSDrawThumb(dPtr,theControl);
-
- break;
-
- case inUpButton: /* Hilite the high up button */
-
- if (dPtr->altButton) {/* Check if alt button */
- if (cPtr->contrlHilite == 0 ||
- cPtr->contrlMin == cPtr->contrlMax)
- DSFrameLUpBtn();
- else
- DSFillLUpBtn();
- }
-
- else { /* Nope, using regular button */
- if (cPtr->contrlHilite == 0 ||
- cPtr->contrlMin == cPtr->contrlMax)
- DSFrameHUpBtn();
- else
- DSFillHUpBtn();
- }
-
- break;
-
- case inDownButton:/* Hilite the high down button */
-
- if (dPtr->altButton) {/* Check if alt button */
- if (cPtr->contrlHilite == 0 ||
- cPtr->contrlMin == cPtr->contrlMax)
- DSFrameLDownBtn();
- else
- DSFillLDownBtn();
- }
-
- else { /* Nope, using regular button */
- if (cPtr->contrlHilite == 0 ||
- cPtr->contrlMin == cPtr->contrlMax)
- DSFrameHDownBtn();
- else
- DSFillHDownBtn();
- }
-
- }
-
- }
-
- }
-
- break;
-
- case testCntl: /* Test the control */
-
- if (dPtr) { /* Check if dual pointer valid */
-
- if (cPtr->contrlHilite != -1) {/* Check if control active*/
-
- /* Check if valid to process */
- if (cPtr->contrlMin != cPtr->contrlMax) {
-
- /* Check if within the rect area*/
- if (PtInRect(param,&cPtr->contrlRect))
- status = DSTestControl(dPtr,param);/* Find part */
-
- }
-
- }
-
- }
-
- break;
-
- case calcCRgns: /* Calculate control's region */
-
- if (dPtr) { /* Check if dual pointer valid */
-
- if (!(param & 0x80000000L))/* Check if want whole control*/
- RectRgn((Handle)(param & 0x7fffffffL),&cPtr->contrlRect);
-
- else { /* Want thumb's region */
-
- /* Setup thumb's region area */
- RectRgn((Handle)(param & 0x7fffffffL),&dPtr->cThumb);
-
- /* Setup drag pattern */
- BlockMove(dPtr->ltGrayPat,DragPattern,8L);
-
- }
-
- }
-
- break;
-
- case calcCntlRgn: /* Calculate control's region */
-
- if (dPtr) /* Check if dual pointer valid */
- RectRgn((Handle)(param),&cPtr->contrlRect);
-
- break;
-
- case calcThumbRgn: /* Calculate "thumb" region */
-
- if (dPtr) { /* Check if dual pointer valid */
-
- /* Setup thumb's region area */
- RectRgn((Handle)(param),&dPtr->cThumb);
-
- /* Setup drag pattern */
- BlockMove(dPtr->ltGrayPat,DragPattern,8L);
-
- }
-
- break;
-
- case initCntl: /* Initialized the control */
-
- /* Allocate the data handle */
- if (dHdl = (DSHDL)NewHandle(sizeof(DS))) {
-
- HLock(dHdl); /* Lock it down for initialization*/
-
- dPtr = *dHdl; /* Set dual control pointer */
-
- dPtr->cHdl = theControl; /* Save control for referencing */
-
- dPtr->up = dPtr->down = NIL;/* Init the poly handles */
-
- /* Init the patterns */
- dPtr->blackPat[0] = dPtr->blackPat[1] = 0xffffffffL;
- dPtr->ltGrayPat[0] = dPtr->ltGrayPat[1] = 0x88228822L;
-
- dPtr->hasColor = FALSE; /* Set default to black & white */
-
- dPtr->altButton = FALSE; /* Set not using alternate button*/
-
- /* Check if SysEnvirons valid */
- if ((long)NGetTrapAddress(SysEnvironsTrap,OSTrap) !=
- (long)NGetTrapAddress(UnknownTrap,ToolTrap)) {
-
- SysEnvirons(1,&sysEnv);/* Get system enviroment */
-
- dPtr->hasColor = sysEnv.hasColorQD;/* Save color */
-
- }
-
- DSInitControl(dPtr,cPtr);/* Init the control's parameters*/
-
- cPtr->contrlAction = (ProcPtr)(-1L);/* Set default action*/
-
- cPtr->contrlData = (Handle)dHdl;/* Save the data handle */
-
- }
-
- break;
-
- case dispCntl: /* Dispose the control */
-
- if (dPtr) { /* Check if dual pointer valid */
-
- if (dPtr->up) /* Kill the polys */
- KillPoly(dPtr->up);
- if (dPtr->down)
- KillPoly(dPtr->down);
-
- HUnlock(cPtr->contrlData);/* Unlock it for releasing */
-
- DisposHandle(cPtr->contrlData);/* Release back memory mgr*/
-
- }
-
- cPtr->contrlData = NIL; /* Clear it */
-
- break;
-
- case posCntl: /* Re-position the control */
-
- if (dPtr) /* Check if dual pointer valid */
- DSPositionThumb(dPtr,theControl,param);
-
- break;
-
- case thumbCntl: /* Calculate thumb for dragging */
-
- if (dPtr) /* Check if dual pointer valid */
- DSSetupThumb(dPtr,param);/* Setup thumb for dragging */
-
- break;
-
- case dragCntl: /* Drag the control */
-
- status = 0; /* Only drag thumb! */
-
- break;
-
- case autoTrack: /* Execute control's action */
-
- break;
-
- }
-
- if (cPtr->contrlData) /* Check if valid pointer */
- HUnlock(cPtr->contrlData); /* Unlock for memory manager */
-
- HUnlock(theControl); /* Unlock the control handle */
-
- return(status); /* Return status code */
-
- }
-
- void DSInitControl(dPtr,cPtr)
-
- register DSPTR dPtr; /* Dual control pointer */
- register ControlPtr cPtr; /* Control pointer */
-
- {
-
- register PolyHandle pHdl; /* Working poly handle */
- register short bLen; /* Working button length */
- register short hBLen; /* Working half button length */
- register short hLen; /* Working horizontal length */
- short vLen; /* Working vertical length */
- register short tmp1,tmp2; /* Working temporary variables */
- Rect cRect; /* Working control rect area */
-
- cRect = cPtr->contrlRect; /* Set scroll bar area */
-
- InsetRect(&cRect,1,1); /* Shrink it by one-pixel */
-
- hLen = abs(cRect.right - cRect.left) + 1;/* Set horizontal length */
-
- vLen = abs(cRect.bottom - cRect.top) + 1;/* Set vertical length */
-
- if (hLen > vLen) { /* Check if horizontal is longer*/
-
- dPtr->bLen = vLen; /* Set button length */
-
- dPtr->sLen = hLen + 1; /* Set scroll bar length */
-
- dPtr->hFactor = 1; /* Set horizontal factor */
-
- dPtr->vFactor = 0; /* Set vertical factor */
-
- }
-
- else { /* Nope, must be vertical */
-
- dPtr->bLen = hLen; /* Set button length */
-
- dPtr->sLen = vLen + 1; /* Set scroll bar length */
-
- dPtr->hFactor = 0; /* Set horizontal factor */
-
- dPtr->vFactor = 1; /* Set vertical factor */
-
- }
-
- bLen = dPtr->bLen; /* Set button length */
-
- hBLen = dPtr->hBLen = bLen / 2; /* Set half button length */
-
- dPtr->thumb.top = dPtr->thumb.left = 0;/* Init top.left point */
-
- if (dPtr->hFactor) { /* Check if horizontal position */
-
- dPtr->thumb.bottom = bLen - 1;
- dPtr->thumb.right = hBLen + hBLen / 2;
-
- }
-
- else { /* Nope, it's vertical position */
-
- dPtr->thumb.bottom = hBLen + hBLen / 2;
- dPtr->thumb.right = bLen - 1;
-
- }
-
- tmp1 = hBLen - 1; /* Set temporary calculations */
- tmp2 = hBLen - 2;
-
- /* Create up poly handle */
- if (pHdl = OpenPoly()) { /* Check if got a poly handle */
-
- if (dPtr->hFactor) { /* Check horizontal position */
-
- MoveTo(0,tmp1);
- LineTo(tmp2,tmp2 * 2 + 1);
- LineTo(tmp2,1);
- LineTo(0,tmp1);
-
- }
-
- else { /* Nope, it's vertical position */
-
- MoveTo(tmp1,0);
- LineTo(1,tmp2);
- LineTo(tmp2 * 2 + 1,tmp2);
- LineTo(tmp1,0);
-
- }
-
- ClosePoly(); /* Close the poly handle */
-
- }
-
- if (dPtr->up) /* Check if have old poly handle*/
- KillPoly(dPtr->up); /* Release this poly handle */
-
- dPtr->up = pHdl; /* Set up poly handle */
-
- /* Create down poly handle */
- if (pHdl = OpenPoly()) { /* Check if got a poly handle */
-
- if (dPtr->hFactor) { /* Check horizontal position */
-
- MoveTo(tmp2,tmp1);
- LineTo(0,tmp2 * 2 + 1);
- LineTo(0,1);
- LineTo(tmp2,tmp1);
-
- OffsetPoly(pHdl,hBLen,0);
-
- }
-
- else { /* Nope, it's vertical position */
-
- MoveTo(1,0);
- LineTo(tmp2 * 2 + 1,0);
- LineTo(tmp1,tmp1);
- LineTo(1,0);
-
- OffsetPoly(pHdl,0,hBLen);
-
- }
-
- ClosePoly(); /* Close the poly handle */
-
- }
-
- if (dPtr->down) /* Check if have old poly handle*/
- KillPoly(dPtr->down); /* Release this poly handle */
-
- dPtr->down = pHdl; /* Set down poly handle */
-
- }
-
- void DSCalcThumb(dPtr,cPtr)
-
- register DSPTR dPtr; /* Dual control pointer */
- register ControlPtr cPtr; /* Control pointer */
-
- {
-
- double tmp1,tmp2; /* Working temporary registers */
- register short offset; /* Working pixel offset */
- Rect wRect; /* Working scroll rect area */
-
- /* Make sure this is mimimum */
- cPtr->contrlMin = min(cPtr->contrlMin,cPtr->contrlMax);
-
- /* Make sure this is maximum */
- cPtr->contrlMax = max(cPtr->contrlMin,cPtr->contrlMax);
-
- /* Make sure min < value < max */
- cPtr->contrlValue = min(cPtr->contrlMax,
- max(cPtr->contrlMin,cPtr->contrlValue));
-
- DSSetScrollRgn(dPtr,&wRect); /* Set scroll region */
-
- /* Setup thumb factor calculation*/
- tmp1 = max(abs(wRect.bottom - wRect.top) * dPtr->vFactor,
- abs(wRect.right - wRect.left) * dPtr->hFactor) -
- dPtr->bLen + dPtr->hBLen - 2;
- tmp2 = abs(cPtr->contrlMax - cPtr->contrlMin);
-
- dPtr->tFactor = tmp1 / tmp2; /* Set relative thumb factor */
-
- /* Compute thumb pixel offset */
- tmp1 = cPtr->contrlValue - cPtr->contrlMin;
- tmp2 = tmp1 * dPtr->tFactor;
- offset = tmp2;
-
- dPtr->cThumb = dPtr->thumb; /* Set the thumb rect area */
- OffsetRect(&dPtr->cThumb,wRect.left + offset * dPtr->hFactor,
- wRect.top + offset * dPtr->vFactor);
-
- }
-
- void DSDrawThumb(dPtr,cHdl)
-
- register DSPTR dPtr; /* Dual control pointer */
- register ControlHandle cHdl; /* Control handle */
-
- {
-
- Rect tRect; /* Working thumb rect area */
- ControlPtr cPtr = *cHdl; /* Working control pointer */
-
- DSSetScrollRgn(dPtr,&tRect); /* Set scroll region */
-
- if (cPtr->contrlHilite != 255 && /* Check if can show thumb */
- cPtr->contrlMax > cPtr->contrlMin) {
-
- DSCalcThumb(dPtr,cPtr); /* Re-calculate thumb */
-
- ForeColor((long)(blackColor)); /* Make sure it's black & white */
- BackColor((long)(whiteColor));
-
- DSFillBody(&tRect); /* Fill in scroll bar */
-
- tRect = dPtr->cThumb; /* Set thumb rect area */
-
- DSFrameThumb(&tRect); /* Frame thumb */
-
- InsetRect(&tRect,1,1); /* Inset by one pixel */
-
- DSFillThumb(&tRect); /* Clear inside of the thumb */
-
- }
-
- else /* Nope, don't want scroll region*/
- DSClearBody(&tRect); /* Clear scroll region */
-
- }
-
- void DSPositionThumb(dPtr,cHdl,pt)
-
- register DSPTR dPtr; /* Dual control pointer */
- register ControlHandle cHdl; /* Control handle */
- register Point pt; /* Point position of the thumb */
-
- {
-
- register double offset; /* Working value offset */
-
- if (dPtr->hFactor) /* Check if it's horizontal */
- offset = pt.h; /* Use horizontal offset */
-
- else /* Nope, it's vertical */
- offset = pt.v; /* Use vertical offset */
-
- offset = offset / dPtr->tFactor; /* Reset the control's value */
- (*cHdl)->contrlValue += offset;
-
- DSDrawThumb(dPtr,cHdl); /* Draw da thumb, again! */
-
- }
-
- void DSSetupThumb(dPtr,thumbPtr)
-
- register DSPTR dPtr; /* Dual control pointer */
- register THUMBPTR thumbPtr; /* Thumb's info pointer */
-
- {
-
- register Point msePt; /* Working mouse point */
-
- msePt.h = thumbPtr->limitRect.left;/* Save current mouse down */
- msePt.v = thumbPtr->limitRect.top;
-
- DSSetScrollRgn(dPtr,&thumbPtr->limitRect);/* Set scroll region */
-
- if (dPtr->hFactor) { /* Check if horizontal scroll bar*/
-
- /* Adjust it for mouse position */
- thumbPtr->limitRect.left += msePt.h - dPtr->cThumb.left;
- thumbPtr->limitRect.right -= dPtr->cThumb.right - msePt.h - 1;
-
- /* Set slop rect area */
- thumbPtr->slopRect.top = thumbPtr->limitRect.top - 16;
- thumbPtr->slopRect.bottom = thumbPtr->limitRect.bottom + 16;
- thumbPtr->slopRect.left = -32000; thumbPtr->slopRect.right = 32000;
-
- thumbPtr->axis = hAxisOnly; /* Set axis dragging direction */
-
- }
-
- else { /* Nope, it's vertical scroll bar*/
-
- /* Adjust it for mouse position */
- thumbPtr->limitRect.top += msePt.v - dPtr->cThumb.top;
- thumbPtr->limitRect.bottom -= dPtr->cThumb.bottom - msePt.v - 1;
-
- /* Set slop rect area */
- thumbPtr->slopRect.left = thumbPtr->limitRect.left - 16;
- thumbPtr->slopRect.right = thumbPtr->limitRect.right + 16;
- thumbPtr->slopRect.top = -32000; thumbPtr->slopRect.bottom = 32000;
-
- thumbPtr->axis = vAxisOnly; /* Set axis dragging direction */
-
- }
-
- }
-
- void DSDrawHBtn(dPtr,btn,fill)
-
- register DSPTR dPtr; /* Dual control pointer */
- register PolyHandle btn; /* Poly button handle */
- short fill; /* Fill flag indicator */
-
- {
-
- /* Offset where button */
- OffsetPoly(btn,(*dPtr->cHdl)->contrlRect.left + 1,
- (*dPtr->cHdl)->contrlRect.top + 1);
-
- if (fill) /* Check if filling the arrow */
- DSFillArrow(btn); /* Fill in the arrow button */
-
- else /* Nope, not clearing it */
- DSClearArrow(btn); /* Clear the arrow button */
-
- DSFrameArrow(btn); /* Frame the arrow button */
-
- /* Restore the button */
- OffsetPoly(btn,-(*dPtr->cHdl)->contrlRect.left - 1,
- -(*dPtr->cHdl)->contrlRect.top - 1);
-
- }
-
- void DSDrawLBtn(dPtr,btn,fill)
-
- register DSPTR dPtr; /* Dual control pointer */
- register PolyHandle btn; /* Poly button handle */
- short fill; /* Fill flag indicator */
-
- {
-
- register short tmp1,tmp2; /* Working temporary variables */
- register short offset; /* Working offset */
-
- offset = dPtr->sLen - dPtr->bLen - 1;/* Set relative offset */
-
- /* Offset where button */
- OffsetPoly(btn,tmp1 = (*dPtr->cHdl)->contrlRect.left +
- dPtr->hFactor * offset + 1,
- tmp2 = (*dPtr->cHdl)->contrlRect.top +
- dPtr->vFactor * offset + 1);
-
- if (fill) /* Check if filling the arrow */
- DSFillArrow(btn); /* Fill in the arrow button */
-
- else /* Nope, not clearing it */
- DSClearArrow(btn); /* Clear the arrow button */
-
- DSFrameArrow(btn); /* Frame the arrow button */
-
- OffsetPoly(btn,-tmp1,-tmp2); /* Restore the button */
-
- }
-
- void DSFrameButtons(dPtr)
-
- register DSPTR dPtr; /* Dual control pointer */
-
- {
-
- Rect bRect; /* Working box rect area */
- register short offset; /* Working low button offset */
-
- bRect.left = bRect.top = 0; /* Set left-top point */
-
- bRect.right = bRect.bottom = dPtr->bLen + 1;/* Set right-top point*/
-
- /* Offset the high button box */
- OffsetRect(&bRect,(*dPtr->cHdl)->contrlRect.left,
- (*dPtr->cHdl)->contrlRect.top);
-
- DSClearBody(&bRect); /* Clear the body part */
-
- DSFrameBody(&bRect); /* Frame the high button box */
-
- offset = dPtr->sLen - dPtr->bLen - 1;/* Set low button box offset */
-
- /* Offset the low button box */
- OffsetRect(&bRect,dPtr->hFactor * offset,dPtr->vFactor * offset);
-
- DSClearBody(&bRect); /* Clear the body part */
-
- DSFrameBody(&bRect); /* Frame the low button box */
-
- }
-
- long DSTestControl(dPtr,pt)
-
- register DSPTR dPtr; /* Dual control pointer */
- Point pt; /* Point position */
-
- {
-
- register Rect cRect; /* Working control rect area */
- register Rect tRect; /* Working temp rect area */
- Rect bRect; /* Working button rect area */
- register short offset; /* Working offset */
- short point; /* Working point in region */
- long status = 0; /* Working status indicator */
-
- cRect = (*dPtr->cHdl)->contrlRect;/* Set working control rect area*/
-
- bRect = dPtr->thumb; /* Set the button rect area */
-
- if (dPtr->hFactor) /* Check if horizontal button */
- bRect.right = dPtr->hBLen; /* Adjust for horizontal button */
-
- else
- bRect.bottom = dPtr->hBLen; /* Adjust for vertical button */
-
- tRect = bRect; /* Set the temp rect area */
-
- OffsetRect(&tRect,cRect.left,cRect.top);/* Offset where high up btn*/
-
- if (PtInRect(pt,&tRect)) { /* Check if in high up button */
- status = inUpButton; /* Set high up button */
- dPtr->altButton = FALSE; /* Set not using alternate button*/
- }
-
- if (!status) { /* Check if previous part control*/
-
- /* Adjust for down button */
- OffsetRect(&tRect,dPtr->hFactor * dPtr->hBLen,
- dPtr->vFactor * dPtr->hBLen);
-
- if (PtInRect(pt,&tRect)) { /* Check if the high down button*/
- status = inDownButton; /* Set high down button */
- dPtr->altButton = FALSE; /* Set not using alternate button*/
- }
- }
-
- if (!status) { /* Check if previous part control*/
-
- tRect = bRect; /* Set the temp rect area */
-
- offset = dPtr->sLen - dPtr->bLen;/* Set relative offset */
-
- /* Offset where low up button */
- OffsetRect(&tRect,cRect.left + dPtr->hFactor * offset,
- cRect.top + dPtr->vFactor * offset);
-
- if (PtInRect(pt,&tRect)) { /* Check if the low up button */
- status = inUpButton; /* Set low up button */
- dPtr->altButton = TRUE; /* Set using alternate button */
- }
- }
-
- if (!status) { /* Check if previous part control*/
-
- /* Offset where low down button */
- OffsetRect(&tRect,dPtr->hFactor * dPtr->hBLen,
- dPtr->vFactor * dPtr->hBLen);
-
- if (PtInRect(pt,&tRect)) { /* Check if the low down button */
- status = inDownButton; /* Set low down button */
- dPtr->altButton = TRUE; /* Set using alternate button */
- }
- }
-
- if (!status) { /* Check if previous part control*/
-
- if (PtInRect(pt,&dPtr->cThumb))/* Check if in thumb */
- status = inThumb; /* Set thumb part */
-
- }
-
- if (!status) { /* Check if previous part control*/
-
- /* Set relative point */
- point = pt.h * dPtr->hFactor + pt.v * dPtr->vFactor;
-
- /* Set relative offset */
- offset = dPtr->cThumb.left * dPtr->hFactor +
- dPtr->cThumb.top * dPtr->vFactor;
-
- if (point > offset) /* Check if in down page region */
- status = inPageDown; /* Set down page region */
-
- else
- status = inPageUp; /* Set up page region */
-
- }
-
- return(status); /* Return status indicator */
-
- }
-
- DSSetScrollRgn(dPtr,scrollRgn)
-
- register DSPTR dPtr; /* Dual control pointer */
- register Rect *scrollRgn; /* Scrolling region area */
-
- {
-
- *scrollRgn = (*dPtr->cHdl)->contrlRect;/* Set scroll region area */
-
- InsetRect(scrollRgn,1,1); /* Shrink it a bit */
-
- if (dPtr->hFactor) { /* Check if horizontal bar */
-
- scrollRgn->left += dPtr->bLen; /* Adjust the rect area */
- scrollRgn->right -= dPtr->bLen;
-
- }
-
- else { /* It's a vertical scroll bar */
-
- scrollRgn->top += dPtr->bLen; /* Adjust the rect area */
- scrollRgn->bottom -= dPtr->bLen;
-
- }
-
- }
-
- void DSGetBackGround(color) RGBColor *color; { GetBackColor(color); }
- void DSGetForeGround(color) RGBColor *color; { GetForeColor(color); }
- void DSSetBackGround(color) RGBColor *color; { RGBBackColor(color); }
- void DSSetForeGround(color) RGBColor *color; { RGBForeColor(color); }
-
- void DSEraseRect(rect) Rect *rect; { EraseRect(rect); }
- void DSFrameRect(rect) Rect *rect; { FrameRect(rect); }
- void DSFillRect(rect,pattern) Rect *rect; Pattern *pattern;
- { FillRect(rect,pattern); }
- void DSErasePoly(poly) PolyHandle poly; { ErasePoly(poly); }
- void DSFramePoly(poly) PolyHandle poly; { FramePoly(poly); }
- void DSFillPoly(poly,pattern) PolyHandle poly; Pattern *pattern;
- { FillPoly(poly,pattern); }
-
- void DSDrawObject(cHdl,getGround,setGround,object,color,arg1,arg2)
-
- ControlHandle cHdl; /* Control handle */
- ProcPtr getGround; /* Get back/fore ground proc */
- ProcPtr setGround; /* Set back/fore ground proc */
- ProcPtr object; /* Draw object proc */
- short color; /* Color index */
- long arg1,arg2; /* Argument's parameters */
-
- {
-
- AuxCtlHndl acHdl = NIL; /* Working aux color handle */
- RGBColor oldColor; /* Working old color */
- RGBColor newColor; /* Working new color */
-
- /* Check if has color monitor */
- if ((*((DSHDL)((*cHdl)->contrlData)))->hasColor) {
-
- GetAuxCtl(cHdl,&acHdl); /* Get control's color info */
-
- if (acHdl) { /* Check if really got it! */
-
- (*getGround)(&oldColor); /* Get original back-ground color*/
-
- /* Get body's color */
- newColor = (*(*acHdl)->acCTable)->ctTable[color].rgb;
-
- (*setGround)(&newColor); /* Set to control's body color */
-
- }
-
- }
-
- (*object)(arg1,arg2); /* Draw the object */
-
- if (acHdl) /* Check if have aux color info */
- (*setGround)(&oldColor); /* Restore back-ground color */
-
- }
-
-